/*
 * @Descripttion: 获取医师的工作信息
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-05-06 19:56:35
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-05-06 20:33:35
 */
const DB = require('../../lib/DB')
const { Success, Fail } = require('../../lib/Response')

module.exports = async function (ctx, next) {
    try {
        // 预约数量
        const the_reservation_number = await DB.models.foresee.count({ where: { state: '等待处理', doctor_id: ctx.session.doctor.id } })
        // 处方数量
        const number_of_prescription = await DB.models.prescription.count({ where: { doctor: ctx.session.doctor.id } })
        // 开药次数
        const prescribing_the_number = await DB.models.prescription_sheet.count()
        // 拿药次数
        const number_of_medicine = await DB.models.doctor_medicine_lib.count({ where: { doctor: ctx.session.doctor.id } })


        ctx.body = new Success({
            the_reservation_number,
            number_of_prescription,
            prescribing_the_number,
            number_of_medicine,
        })
        await next();
    } catch (e) {
        ctx.body = new Fail(e.message)
    }
}